home *** CD-ROM | disk | FTP | other *** search
- unit ActionTracer4FormU;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls, Buttons;
-
- type
- TActionTracerForm = class(TForm)
- chkOn: TCheckBox;
- chkSkipHints: TCheckBox;
- btnClearList: TSpeedButton;
- lstActions: TListBox;
- Label1: TLabel;
- procedure btnClearListClick(Sender: TObject);
- procedure AppActionExecute(Action: TBasicAction;
- var Handled: Boolean);
- procedure AppShortCut(var Msg: TWMKey; var Handled: Boolean);
- procedure FormCreate(Sender: TObject);
- end;
-
- implementation
-
- {$R *.DFM}
-
- uses
- StdActns;
-
- //Form variable moved here so:
- // a) The form won't be auto-created - it will be entirely managed from here
- // b) No one else can mess with the form
- var
- ActionTracerForm: TActionTracerForm;
-
- procedure TActionTracerForm.btnClearListClick(Sender: TObject);
- begin
- lstActions.Items.Clear
- end;
-
- procedure TActionTracerForm.AppActionExecute(Action: TBasicAction;
- var Handled: Boolean);
- begin
- //If we are tracing
- if chkOn.Checked then
- begin
- //If not tracing hint actions, then ignore them
- if (Action is THintAction) and chkSkipHints.Checked then
- Exit;
- //Format a nice string and add it to the list
- lstActions.Items.Add(Format('%s: %s', [Action.Name, Action.ClassName]));
- //Make last item selected, which forces it into view
- lstActions.ItemIndex := lstActions.Items.Count - 1
- end
- end;
-
- procedure TActionTracerForm.AppShortCut(var Msg: TWMKey;
- var Handled: Boolean);
-
- function KeyDown(KeyCode: Integer): Boolean;
- begin
- Result := GetKeyState(KeyCode) and $8000 > 0
- end;
-
- begin
- if (Msg.CharCode = Ord('Z')) and KeyDown(vk_Control) and
- KeyDown(vk_Shift) and KeyDown(vk_Menu) then
- Show
- end;
-
- procedure TActionTracerForm.FormCreate(Sender: TObject);
- begin
- Application.OnActionExecute := AppActionExecute;
- Application.OnShortCut := AppShortCut;
- end;
-
- initialization
- ActionTracerForm := TActionTracerForm.Create(nil);
- if FindCmdLineSwitch('ActionTrace', ['-', '/'], True) then
- ActionTracerForm.Show
- finalization
- ActionTracerForm.Free;
- ActionTracerForm := nil
- end.
-